<?php

/**
 * addressformat actions.
 *
 * @package    sf_sandbox
 * @subpackage addressformat
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class addressformatActions extends sfActions
{
  public function executeIndex()
  {
    $this->address_formatList = AddressFormatPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new AddressFormatForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new AddressFormatForm(AddressFormatPeer::retrieveByPk($request->getParameter('address_format_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new AddressFormatForm(AddressFormatPeer::retrieveByPk($request->getParameter('address_format_id')));

    $this->form->bind($request->getParameter('address_format'));
    if ($this->form->isValid())
    {
      $address_format = $this->form->save();

      $this->redirect('addressformat/edit?address_format_id='.$address_format->getAddressFormatId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($address_format = AddressFormatPeer::retrieveByPk($request->getParameter('address_format_id')));

    $address_format->delete();

    $this->redirect('addressformat/index');
  }
}
